home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
tex
/
bfind406.zip
/
BFIND.DOC
next >
Wrap
Text File
|
1994-06-18
|
7KB
|
154 lines
BFIND.DOC
06/18/94
The BFIND.EXE program adds Boolean logic to DOS's FIND command. Features:
* In most ways, identical to DOS FIND command except...
* Adds AND, OR, NOT, and XOR options to searches (finding all lines with
"Apples" or "Bananas", for example)
* Allows you to specify the starting column of the desired string
* Adds a pause (/P) option to have the output pause every 24 lines
* Avoids need to include the search string in quotation marks so you can
use the program more easily in batch commands.
The DOS FIND command allows you to find lines in a text file which contain a
given string. You can also have the program tell you how many lines met the
search criteria without actually viewing them which is an ideal way to find out
how many times a given string appears in your file. You can even use FIND to
tell you how many total lines are in a given file just by requesting a string
that you know will never appear in your file like "#X$S$".
BFIND adds to these capabilities. It gives you the power of AND, OR, NOT, and
XOR allowing you to find any line, for example, that contains both "Apples" and
"Oranges" or to present any lines that contain either "Bananas" and "Pears". In
addition, you can do column-specific searching, finding only those lines, say,
that contain "PRINT" beginning in column 10.
Some of the default values for this routine can be set using the CONFIGWS.EXE
program contained in BFINDymm.ZIP.
Syntax:
BFIND [ /V | /-V ] [ /C | /-C ] [ /N | /-N ] [ /I | /-I ] [ /P | /-P ]
[ /-HEADER | /HEADER ] { search } infile [ /? ] [ >filename ]
where:
/V says to find those items that do NOT match the specification
/-V is the opposite of /V and is typically the default; CONFIGWS-able
/C says to show the count of the items found (no individual lines)
/-C is the opposite of /C and is typically the default; CONFIGWS-able
/N says to number the output lines
/-N is the opposite of /N and is typically the default; CONFIGWS-able
/I says to make it a case-insensitive search
/-I is the opposite of /I and is typically the default; CONFIGWS-able
/P says to have the display pause every 24 lines
/-P is the opposite of /P and is typically the default; CONFIGWS-able
/-HEADER says to skip the normal -----infile line
/HEADER is the opposite of /-HEAD and is typically the default
search is described below
infile is the name of the input file
/? or /HELP or HELP gives you this syntactical help
>filename is standard DOS redirection, letting you send results to a file
instead of to the screen
BFIND directly supports all FIND options except for allowing multiple file
names; use the DOS FOR command if you want that. Options supported include the
/V, /C, /N, /I (which was added in MS-DOS 5.0), infile, /?, and the redirection
specifications. FIND makes the file name be position sensitive--you cannot put
the infile name before the switches--and BFIND adheres to that rule.
For search, the syntax is:
[ ( ]... search_item [ boolean [ ( ]... search_item [ ) ]...] [ ) ]...
where:
( and ) are used to group items
search_item is shown below
boolean is AND, OR, or XOR (NOT is included with search_item)
for search_item, the syntax is:
[ NOT ] "string" [ column ]
where:
NOT is obvious
string the string to search; the quotation marks are typically not
required unless the string contains a space or a reserved word
column is the column in which the string must be found.
So, let's cover some examples:
BFIND "Bugs Bunny" OR "Elmer Fudd" TEST.TXT
Finds any lines in the file TEST.TXT containing either "Bugs Bunny" or "Elmer
Fudd" in them.
BFIND (Apples or Oranges) AND NOT Pears TEST2.TXT
Finds any lines in the file TEST2.TXT which contain the words "Apples" or
"Oranges" in them and ignores any lines containing "Pears". Note that the
quotes around the search words are not required unless the words include spaces
or unless they could be confused with some other keywords. "BFIND OR OR AND
TEST3.TXT" might cause the program to get confused since "OR" and "AND", which
you want to look for as also keywords.
BFIND /C "Bugs Bunny" AND Martians TEST.TXT
Gives you a total for the number of lines containing both "Bugs Bunny" and
"Martians".
You can press the Esc character to abort the search early.
Remember that BFIND, unlike FIND, typically doesn't require the search string to
be in quotes. As a result, you can create a text file (presume it's called
C:\BAT\PHONE.TXT) containing phone numbers or something and then create a batch
file (like PHONES.BAT) that looks like this:
BFIND %1 %2 %3 %4 %5 C:\BAT\PHONE.TXT
When you want to find a phone number, you just say "PHONE name". This is a
little more natural that using FIND which would require that you enclose the
name in quotes. You can still use the Boolean operators in BFIND; the batch
file above would allow up to five parameters. Remember, though, if you're doing
multiple-word names (like "Bruce Guthrie"), you have to enclose the name in
quotes or use AND. Both of the following would work with the batch file shown
above (although the second option may produce more hits):
PHONE "Bruce Guthrie"
PHONE Bruce AND Guthrie
Return codes:
BFIND returns the following ERRORLEVEL codes:
0 = no problems, string found
1 = no problems, string not found
255 = syntax problems, file not found, or /? requested
Author:
This program was written by Bruce Guthrie of Wayne Software. It is free for use
and redistribution provided relevant documentation is kept with the program, no
changes are made to the program or documentation, and it is not bundled with
commercial programs or charged for separately. People who need to bundle it in
for-sale packages must pay a $50 registration fee to "Wayne Software" at the
following address.
Additional information about this and other Wayne Software programs can be found
in the file BRUCEymm.DOC which should be included in the original ZIP file.
("ymm" is replaced by the last digit of the year and the two digit month of the
release. BRUCE312.DOC came out in December 1993. This same naming convention
is used in naming the ZIP file that this program was included in.) Comments and
suggestions can also be sent to:
Bruce Guthrie
Wayne Software
113 Sheffield St.
Silver Spring, MD 20910
fax: (301) 588-8986
Foreign users: Please provide an Internet e-mail address in all correspondence.